// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";

import * as filters from "./filters";

import directives from "./directive";

import API from "./https/api";
import { encode, decode } from "./assets/js/base64.js";
import {
  hasThisButton,
  getdictName,
  ishasValue,
  alertFn,
  confirmFn,
  TimeTransform,
  recursion,
  getMatched
} from "./assets/js/utils.js";

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
  //判断是否为空
  key == "judgeEmpty" ? (Vue.prototype.judgeEmpty = filters[key]) : null;
});

Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key]);
});

//api
Vue.prototype.API = API;
//加解密
Vue.prototype.encode = encode;
Vue.prototype.decode = decode;
//按钮权限
Vue.prototype.hasButton = hasThisButton;
//获取字典
Vue.prototype.getdictName = getdictName;
//判断表格是否有值
Vue.prototype.ishasValue = ishasValue;
//成功错误信息
Vue.prototype.$alertFn = {
  success: msg => {
    alertFn(msg, true);
  },
  error: msg => {
    alertFn(msg, false);
  }
};
//确认框
Vue.prototype.$confirmFn = confirmFn;
//时间格式化
Vue.prototype.toTime = time =>
  time ? TimeTransform("YYYY-MM-DD hh:mm", time) : "--";
//递归获取数据
Vue.prototype.recursion = recursion;
//获取面包屑
Vue.prototype.getMatched = getMatched;
